import '@/styles/main.css'
import './styles/scrollbar.scss'
import { createApp } from 'vue'
import router from './router'
import App from './App.vue'
import Directives from '@/directives'
// import './styles/element-plus.scss'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { createPinia } from 'pinia'
import lazyPlugin from 'vue3-lazy'
import loadingImg from '@/imgs/img-loading.gif'
import errorImg from '@/imgs/img-error.png'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import NotData from '@/components/business/NotData/index.vue'

const app = createApp(App)

app.use(router)
app.use(Directives)
app.use(ElementPlus, { locale: zhCn })
app.use(createPinia())
app.use(lazyPlugin, {
	loading: loadingImg,
	error: errorImg,
})
app.component('NotData', NotData)
//全局注册图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}

app.mount('#app')

// 读取配置文件
fetch('/json/ap.confg.json').then((res) => {
	res.json().then((data) => {
		if (!data) {
			return
		}
		window.webConfigData = data
	})
})